package com.nl.lib_core.base.adapter

import android.content.Context
import androidx.recyclerview.widget.RecyclerView

/** 作者: wangfei 创建时间: 2021/12/10 包名: com.nl.lib_core.base.adapter 类名: BaseClickContorlAdapter */
abstract class BaseClickControlAdapter<E : ItemEntityImp, VH : RecyclerView.ViewHolder>(
    override var mContext: Context
) : BaseAdapter<E, VH>(mContext) {

  override fun onBindViewHolder(holder: VH, position: Int) {
    val e = mList[position]
    if (mItemClickListener != null && e.isNeedOnClick) {
      holder.itemView.setOnClickListener { mItemClickListener!!.onItemClick(e, position) }
    }
    if (mOnItemLongClickListener != null && e.isNeedOnLongClick) {
      holder.itemView.setOnLongClickListener {
        mOnItemLongClickListener!!.onItemLongClick(e, position)
      }
    }
    onBindData(holder, e, position)
  }
}
